//
// Created by xili on 2024/8/3 14:00.
// Go big or go home.
//
#include <vector>

using namespace std;

class Solution {
public:
    vector<int> findEvenNumbers(vector<int> &digits) {
        vector<int> ans;
        vector<int> num(10, 0);
        //统计每个数字出现的次数
        for (auto &item: digits) {
            num[item]++;
        }
        //对所有的三位数字进行判断 [100...998]
        for (int i = 100; i < 998; i += 2) {
            vector<int> cnt(10, 0);
            int val = i;
            bool flag = true;
            while (val) {
                int c = val % 10;
                cnt[c]++;
                if (cnt[c] > num[c]) {
                    flag = false;
                    break;
                }
                val /= 10;
            }
            if (flag) {
                ans.emplace_back(i);
            }
        }
        return ans;
    }
};